package com.transfiguro.datamodel.csmodels;

import com.transfiguro.datamodel.GenericStatement;
import com.transfiguro.datamodel.Statement;

public class CSVariableDeclarationStatement extends GenericStatement {
    private String variableName;
    private String accessModifier;
    private boolean isConvertible;
    private boolean hasValue;
    private String type; //String type??? Should types be defined separately???
    private double conversionTime;
    private String value;

    public CSVariableDeclarationStatement() {
        REQUIRE_CLOSING = true;
    }

    public boolean isRequireClosing() {
        return REQUIRE_CLOSING;
    }

    public String getVariableName() {
        return variableName;
    }

    public void setVariableName(final String variableName) {
        this.variableName = variableName;
    }

    public String getAccessModifier() {
        return accessModifier;
    }

    public void setAccessModifier(final String accessModifier) {
        this.accessModifier = accessModifier;
    }

    public boolean isConvertible() {
        return isConvertible;
    }

    public void setConvertible(final boolean convertible) {
        isConvertible = convertible;
    }

    public boolean isHasValue() {
        return hasValue;
    }

    public void setHasValue(final boolean hasValue) {
        this.hasValue = hasValue;
    }

    public String getType() {
        return type;
    }

    public void setType(final String type) {
        this.type = type;
    }

    //Trimming to be done for every toString
    @Override
    public String toString() {
        StringBuilder builder = new StringBuilder();
        builder.append('\t').append(accessModifier == null ? "" : accessModifier).append(' ')
                .append(type == null ? "" : type).append(' ').append(variableName);
        //.append(hasValue ? "=" + value : "").append(';');
        if (hasValue) {
            builder.append('=');
            for (final Statement statement : statements) {
                builder.append(statement.toString()).append(statement.isRequireClosing()? ';' : "");
            }
            //builder.append(';');
        } /**else {
         builder.append(';');
         }*/
        return builder.toString().trim();
    }

    public double getConversionTime() {
        return conversionTime;
    }

    public void setConversionTime(final double conversionTime) {
        this.conversionTime = conversionTime;
    }

    public String getValue() {
        return value;
    }

    public void setValue(final String value) {
        this.value = value;
    }
}